package com.ae.shield.common.world.gen.feature;

import com.ae.shield.ModLib;
import com.ae.shield.common.block.BlockList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.WorldGenRegistries;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.IFeatureConfig;
import net.minecraft.world.gen.feature.OreFeatureConfig;
import net.minecraft.world.gen.placement.Placement;
import net.minecraft.world.gen.placement.TopSolidRangeConfig;

public class OreFeature {
    public static ConfiguredFeature<?, ?> ORES_TIN;
    public static ConfiguredFeature<?, ?> ORES_LEAD;
    public static ConfiguredFeature<?, ?> ORES_ALUMINUM;
    public static ConfiguredFeature<?, ?> ORES_SILVER;
    public static ConfiguredFeature<?, ?> ORES_MANGANESE;
    public static ConfiguredFeature<?, ?> ORES_TANTALUM;

    public static void setup() {
        ORES_TIN = register("ore_tin", Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, BlockList.ORES_TIN.get().getDefaultState(), 9))
                .withPlacement(Placement.RANGE.configure(new TopSolidRangeConfig(20, 20, 60)))
                .square()
                .func_242731_b(4));

        ORES_LEAD = register("ore_lead", Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, BlockList.ORES_LEAD.get().getDefaultState(), 8))
                .withPlacement(Placement.RANGE.configure(new TopSolidRangeConfig(0, 0, 40)))
                .square()
                .func_242731_b(2));

        ORES_ALUMINUM = register("ores_aluminum", Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, BlockList.ORES_ALUMINUM.get().getDefaultState(), 8))
                .withPlacement(Placement.RANGE.configure(new TopSolidRangeConfig(40, 40, 85)))
                .square()
                .func_242731_b(4));

        ORES_SILVER = register("ore_silver", Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, BlockList.ORES_SILVER.get().getDefaultState(), 8))
                .withPlacement(Placement.RANGE.configure(new TopSolidRangeConfig(0, 0, 40)))
                .square()
                .func_242731_b(2));

        ORES_MANGANESE = register("ores_manganese", Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, BlockList.ORES_MANGANESE.get().getDefaultState(), 9))
                .withPlacement(Placement.RANGE.configure(new TopSolidRangeConfig(20, 20, 40)))
                .square()
                .func_242731_b(2));

        ORES_TANTALUM = register("ores_tantalum", Feature.ORE.withConfiguration(new OreFeatureConfig(OreFeatureConfig.FillerBlockType.BASE_STONE_OVERWORLD, BlockList.ORES_TANTALUM.get().getDefaultState(), 9))
                .withPlacement(Placement.RANGE.configure(new TopSolidRangeConfig(20, 20, 35)))
                .square()
                .func_242731_b(2));

    }

    private static <FC extends IFeatureConfig> ConfiguredFeature<FC, ?> register(String key, ConfiguredFeature<FC, ?> configuredFeature) {
        return Registry.register(WorldGenRegistries.CONFIGURED_FEATURE, new ResourceLocation(ModLib.MOD_ID, key), configuredFeature);
    }
}
